import { FormSchema, commonRules } from '@/components/Form';
import { getDictOptions } from '@/utils/dict';
import { DictEnum } from '@/enums/dictEnum';
import { IconEnum } from '@/enums/appEnum';
import { useRender } from '@/hooks/component/useRender';
import { areadata } from '@/utils/areadata';
const { renderIcon } = useRender();
export const drawerSchemas: FormSchema[] = [
  {
    label: '地址id',
    field: 'addressId',
    component: 'Input',
    show: false,
    required: false,
  },
  {
    label: '客户id',
    field: 'addressCustomerId',
    component: 'Input',
    show: false,
    required: true,
  },
  {
    label: '国家/地区',
    field: 'addressCountryId',
    required: true,
    component: 'Select',
    componentProps: {
      allowClear: false,
      options: getDictOptions(DictEnum.COUNTRY),
    },
  },
  {
    label: '联系人',
    field: 'addressContactName',
    component: 'Input',
    required: true,
  },
  {
    label: '联系电话',
    field: 'addressTelephone',
    component: 'Input',
    rules: commonRules('phone', true),
    renderComponentContent() {
      return {
        addonBefore: () => renderIcon(IconEnum.PHONE),
      };
    },
  },
  {
    label: '地址行1',
    field: 'addressLine1',
    component: 'InputTextArea',
    required: true,
    componentProps: {
      rows: 2,
    },
  },
  {
    label: '地址行2',
    field: 'addressLine2',
    component: 'InputTextArea',
    componentProps: {
      rows: 2,
    },
  },
  {
    label: '省/市',
    field: 'area',
    required: true,
    component: 'Cascader',
    componentProps: {
      options: areadata,
      fieldNames: {
        label: 'name',
        value: 'name',
        children: 'children',
      },
      getPopupContainer: () => document.body,
    },
  },
  {
    label: '邮政编码',
    field: 'addressPostalCode',
    component: 'Input',
  },
  {
    label: '账单地址',
    field: 'addressIsEmailAddress',
    component: 'Checkbox',
  },
  {
    label: '备注',
    field: 'remark',
    required: true,
    component: 'InputTextArea',
    componentProps: {
      rows: 2,
    },
  },
];
